/* Copyright 2012 Dustin Mitchell <dmmitche [at] gmail [dot] com>
 *
 * Licensed under the GPLv3.  See included LICENSE.txt for full details.
 */

#ifndef __UART__
#define __UART__

#include <termios.h>
#include <sys/types.h>

#include "hw_module.h"

struct uart_hw_module
{
  struct hw_module *hw;
  const char *dev_path;
};

struct uart
{
  int fd;
  struct termios old_ios;
};

int uart_create (struct uart *uart, struct uart_hw_module *mod, int baud);

void uart_destroy (struct uart *uart);

ssize_t uart_read (struct uart *uart, void *buff, size_t count);

ssize_t uart_write (struct uart *uart, const void *buff, size_t count);

int uart_get_fd (struct uart *uart);

#ifndef ARM
int uart_open_slave_pt (struct uart *uart);
#endif

#endif /* __UART__ */
